using MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors;
using QFramework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Projectsurviva
{
    public class SaveSystem : AbstractSystem
    {
        protected override void OnInit()
        {
            ActionKit.OnGUI.Register(() =>
            {
                if (Input.GetKey(KeyCode.L))
                {
                    foreach (var key in keys)
                    {
                        GUILayout.Label(key + ":" + PlayerPrefs.GetInt(key));
                        GUILayout.Label(key + ":" + PlayerPrefs.GetString(key));
                        GUILayout.Label(key + ":" + PlayerPrefs.GetFloat(key));
                    }
                }

            });
        }
        public HashSet<string> keys= new HashSet<string>();
        public void Save()
        {
        }
        public bool LoadBool(string key,bool defaultValue=false)
        {
            keys.Add(key);
            return PlayerPrefs.GetInt(key, defaultValue ? 1 : 0) == 1;
        }
        public void SaveBool(string key ,bool value  )
        {
            keys.Add(key);
            PlayerPrefs.SetInt(key, value ? 1 : 0);
        }
        /// <summary>
        /// Save int 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public int LoadInt(string key, int defaultValue =0)
        {
            keys.Add(key);
            return PlayerPrefs.GetInt(key, defaultValue ) ;
        }
        public void SaveInt(string key, int value)
        {
            keys.Add(key);
            PlayerPrefs.SetInt(key, value );
        }
        /// <summary>
        /// Save  String
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public string LoadString(string key, string defaultValue =default)
        {
            keys.Add(key);
            return PlayerPrefs.GetString(key, defaultValue );
        }
        public void SaveString(string key, string value)
        {
            keys.Add(key);
            PlayerPrefs.SetString(key, value );
        }
        public void Load()
        {

        }

    }

}
